package com.soulkun.smarthome.ui.main.personal.adapter

import android.content.Context
import android.view.View
import androidx.databinding.ObservableArrayList
import androidx.databinding.ViewDataBinding
import com.soulkun.smarthome.R
import com.soulkun.smarthome.databinding.AppRecycleItemMainPersonalFamilyCreateRoomListBinding
import com.soulkun.smarthome.logic.vo.RoomSelectVO
import soulkun.library.mvvm.adapter.BaseDataBindingRecyclerViewAdapter

class AppMainPersonalFamilyCreateRoomListAdapter(context: Context, modelList: ObservableArrayList<RoomSelectVO>) :
    BaseDataBindingRecyclerViewAdapter<RoomSelectVO>(context, modelList) {

    private val onClickListener = { binding: ViewDataBinding ->
        View.OnClickListener {
            (binding as AppRecycleItemMainPersonalFamilyCreateRoomListBinding).room?.let {
                it.isSelected.set(!it.isSelected.get())
            }
        }
    }

    override fun getContentLayoutResId(): Int {
        return R.layout.app_recycle_item_main_personal_family_create_room_list
    }

    override fun setContentViewHolderCreateListener(binding: ViewDataBinding) {
        (binding as AppRecycleItemMainPersonalFamilyCreateRoomListBinding).onClickListener =
            onClickListener(binding)
    }

    override fun setContentViewHolderBindListener(binding: ViewDataBinding, dataPosition: Int) {
        (binding as AppRecycleItemMainPersonalFamilyCreateRoomListBinding).room = dataList[dataPosition]
    }

}